package com.itheima.web.controller;

import com.itheima.vo.AnalysisSummaryVo;
import com.itheima.web.manager.AnalysisManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

@RestController
public class AnalysisController {

    @Autowired
    private AnalysisManager analysisManager;

    //概要统计
    @GetMapping("/dashboard/summary")
    public AnalysisSummaryVo summary(){
        return analysisManager.summary();
    }

    //新增,活跃,次日留存
    @GetMapping("/dashboard/users")
    public Map<String, List> countDashboard(String type,
                                            @RequestParam(value = "sd") Long startTime,
                                            @RequestParam(value = "ed") Long endTime) throws ParseException {
        return analysisManager.countDashboard(type, startTime, endTime);
    }
}
